-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to new major version of elm-sha1 #5
Conversation
* Favor use of Bytes over List Int * Remove unused dependencies
* KeyBytes/MessageBytes didn't make sense given refactorings * Rename normalizeKey to makeKey (fits better with refactorings)
* `toHex` and `toBase64` can never be `Err` * Keep hex form in lower case, as is canonical NOTE: This breaks the API, so is a MAJOR update
Man this is awesome!! I see a bunch of improvements, the code is clearer and less deps 👍 Yes, I think it makes more sense to rename that function Thanks for this |
Cool, glad it looks good 😄. I also wondered if it makes sense adding the ability to make digests from |
Dropping the |
@TSFoster sorry I've been busy 🤔 tough question. To make simpler this package we could leave it as it is. I mean, if someone has the key in bytes it can convert it to string representation? And the msg too. I don't have a lot of experience using hmac, but what I've used is key and msg as string and not many usages in bytes, being in ruby or JS. I think is not about all the options this package can provide but more about how is going to beused. What do you think? |
There is something to consider about |
As custom types are Very Good and encouraged in Elm, I'd suggest exposing an opaque You could do the same with a If you make a |
I think |
Cool. How do you want to move forward with this? I'm happy to make the refactor and add it to this PR/a new one? Or do you want to do it? In terms of implementation, I'd imagined something like: module Internal.Key exposing (Key(..))
type Key = Key (List Int) module HmacSha1.Key exposing (Key, fromString, fromBytes)
import Internal.Key as Key
type alias Key = Key.Key That's how I've seen handling types that are opaque externally, but not internally |
I would add the refactor on this PR. And make just one opaque module module HmacSha1.Key exposing (Key, fromString, fromBytes)
type Key = Key (List Int) WDYT? |
Does that make sense? I don't know how to write it clearly! |
Ahh I see! Yes, it makes total sense. I need to learn more on package creation! haha. Thanks for the explanation and discussion |
Cool, no problem. You want to do it, or me? |
If you have time would be nice, I can do it this weekend if is not done |
I've added the functionality using the API we discussed. Some work still needs to be done on the tests and the doc tests |
@TSFoster very nice! I'll finish it up, thank you for this |
Hey,
I was able to do the work this morning. I've tried to split the commits up into as many logical parts as I can, but 11b90b8 is the main one.
I think it's made about a 20% performance increase, from rough testing.
The changes mean that there were a couple of unnecessary dependencies, and also that the type signatures of
toHex
andtoBase64
changed (for the better, I think). I left those changes till the final commits.As the changes to
toHex
andtoBase64
mean a major version change anyway, I wanted to ask what you think about renamingtoIntList
? In the rewrite of elm-sha1, @folkertdev went fortoByteValues
, which I think is good — it describes what theList Int
actually represents, so it gives it better meaning.